use emporium
go
sp_RENAME 'TG_Actividad.actividad_tipoprod', 'Actividad_TipoProd' , 'COLUMN';
go
sp_RENAME 'TG_Actividad.actividad_tipodocu', 'Actividad_TipoDocu' , 'COLUMN';
go
sp_RENAME 'TG_Actividad.actividad_clase', 'Actividad_Clase' , 'COLUMN';
go
sp_RENAME 'TG_Actividad.actividad_guia', 'Actividad_Guia' , 'COLUMN';
go


GO
/****** Object:  ForeignKey [FK_PR_Movimiento_PR_OrdenProduccion]    Script Date: 11/20/2011 23:04:24 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PR_Movimiento_PR_OrdenProduccion]') AND parent_object_id = OBJECT_ID(N'[dbo].[PR_Movimiento]'))
ALTER TABLE [dbo].[PR_Movimiento] DROP CONSTRAINT [FK_PR_Movimiento_PR_OrdenProduccion]
GO
/****** Object:  ForeignKey [FK_PR_MovimientoDetalle_PR_Movimiento]    Script Date: 11/20/2011 23:04:25 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PR_MovimientoDetalle_PR_Movimiento]') AND parent_object_id = OBJECT_ID(N'[dbo].[PR_MovimientoDetalle]'))
ALTER TABLE [dbo].[PR_MovimientoDetalle] DROP CONSTRAINT [FK_PR_MovimientoDetalle_PR_Movimiento]
GO
/****** Object:  Table [dbo].[PR_MovimientoDetalle]    Script Date: 11/20/2011 23:04:25 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PR_MovimientoDetalle_PR_Movimiento]') AND parent_object_id = OBJECT_ID(N'[dbo].[PR_MovimientoDetalle]'))
ALTER TABLE [dbo].[PR_MovimientoDetalle] DROP CONSTRAINT [FK_PR_MovimientoDetalle_PR_Movimiento]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_MovimientoDetalle]') AND type in (N'U'))
DROP TABLE [dbo].[PR_MovimientoDetalle]
GO
/****** Object:  Table [dbo].[PR_Movimiento]    Script Date: 11/20/2011 23:04:24 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PR_Movimiento_PR_OrdenProduccion]') AND parent_object_id = OBJECT_ID(N'[dbo].[PR_Movimiento]'))
ALTER TABLE [dbo].[PR_Movimiento] DROP CONSTRAINT [FK_PR_Movimiento_PR_OrdenProduccion]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Movimiento]') AND type in (N'U'))
DROP TABLE [dbo].[PR_Movimiento]
GO
/****** Object:  Table [dbo].[PR_ResumenPaquetes]    Script Date: 11/20/2011 23:04:25 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_ResumenPaquetes]') AND type in (N'U'))
DROP TABLE [dbo].[PR_ResumenPaquetes]
GO
/****** Object:  Table [dbo].[PR_MovimientoAcumulado]    Script Date: 11/20/2011 23:04:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_MovimientoAcumulado]') AND type in (N'U'))
DROP TABLE [dbo].[PR_MovimientoAcumulado]
GO
/****** Object:  Table [dbo].[PR_MovimientoAcumulado]    Script Date: 11/20/2011 23:04:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_MovimientoAcumulado]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PR_MovimientoAcumulado](
	[MovAcu_Id] [int] IDENTITY(1,1) NOT NULL,
	[OrdPro_Id] [int] NOT NULL,
	[Sector_Id] [int] NOT NULL,
	[Sector_Nombre] [varchar](150) NULL,
	[Proceso_Id] [int] NOT NULL,
	[Proceso_Descripcion] [varchar](100) NULL,
	[Actividad_Id] [int] NOT NULL,
	[Actividad_Descripcion] [varchar](100) NULL,
	[Linea_Id] [int] NOT NULL,
	[Linea_Descripcion] [varchar](100) NULL,
	[Estilo_Id] [int] NOT NULL,
	[Combinacion_Id] [int] NOT NULL,
	[MovAcu_Color] [varchar](50) NOT NULL,
	[Talla_Id] [int] NOT NULL,
	[MovAcu_Talla] [varchar](50) NOT NULL,
	[MovAcu_Ingreso] [int] NOT NULL,
	[MovAcu_Proceso] [int] NOT NULL,
	[MovAcu_Merma] [int] NOT NULL,
 CONSTRAINT [PK_PR_MovimientoAcumulado] PRIMARY KEY CLUSTERED 
(
	[MovAcu_Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[PR_ResumenPaquetes]    Script Date: 11/20/2011 23:04:25 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_ResumenPaquetes]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PR_ResumenPaquetes](
	[Resumen_Id] [int] IDENTITY(1,1) NOT NULL,
	[OrdPro_Id] [int] NOT NULL,
	[Sector_Ori_Id] [int] NOT NULL,
	[Sector_Ori_Nombre] [varchar](150) NULL,
	[Proceso_Ori_Id] [int] NOT NULL,
	[Proceso_Ori_Descripcion] [varchar](100) NULL,
	[Actividad_Ori_Id] [int] NOT NULL,
	[Actividad_Ori_Descripcion] [varchar](100) NULL,
	[Linea_Ori_Id] [int] NOT NULL,
	[Linea_Ori_Descripcion] [varchar](100) NULL,
	[OrdCor_Id] [int] NOT NULL,
	[OrdCorPaq_Numero] [int] NOT NULL,
	[Sector_Des_Id] [int] NULL,
	[Sector_Des_Nombre] [varchar](150) NULL,
	[Proceso_Des_Id] [int] NULL,
	[Proceso_Des_Descripcion] [varchar](100) NULL,
	[Actividad_Des_Id] [int] NULL,
	[Actividad_Des_Descripcion] [varchar](100) NULL,
	[Linea_Des_Id] [int] NOT NULL,
	[Linea_Des_Descripcion] [varchar](100) NULL,
	[Movimiento_Id] [int] NULL,
	[Movimiento_Fecha] [datetime] NULL,
 CONSTRAINT [PK_PR_ResumenPaquetes] PRIMARY KEY CLUSTERED 
(
	[Resumen_Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[PR_Movimiento]    Script Date: 11/20/2011 23:04:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_Movimiento]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PR_Movimiento](
	[Movimiento_Id] [int] IDENTITY(1,1) NOT NULL,
	[Movimiento_Fecha] [datetime] NOT NULL,
	[OrdPro_Id] [int] NOT NULL,
	[Estilo_Id] [int] NOT NULL,
	[Proceso_Id] [int] NOT NULL,
	[Proceso_Descripcion] [varchar](100) NULL,
	[Actividad_Id] [int] NOT NULL,
	[Actividad_Descripcion] [varchar](100) NULL,
	[Proveedor_Id] [int] NOT NULL,
	[Proveedor_Nombre] [varchar](150) NULL,
	[Linea_Id] [int] NOT NULL,
	[Linea_Descripcion] [varchar](100) NULL,
	[ProcesoDes_Id] [int] NOT NULL,
	[ProcesoDes_Descripcion] [varchar](100) NULL,
	[ActividadDes_Id] [int] NOT NULL,
	[ActividadDes_Descripcion] [varchar](100) NULL,
	[ProveedorDes_Id] [int] NOT NULL,
	[ProveedorDes_Nombre] [varchar](150) NULL,
	[LineaDes_Id] [int] NOT NULL,
	[LineaDes_Descripcion] [varchar](100) NULL,
	[Reproceso_Id] [int] NULL,
	[OrdTra_Tipo] [varchar](5) NULL,
	[OrdTra_Id] [int] NULL,
	[Movimiento_Observacion] [varchar](255) NULL,
	[Usuario_Id] [int] NOT NULL,
 CONSTRAINT [PK_PR_Movimiento] PRIMARY KEY CLUSTERED 
(
	[Movimiento_Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[PR_MovimientoDetalle]    Script Date: 11/20/2011 23:04:25 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PR_MovimientoDetalle]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PR_MovimientoDetalle](
	[MovDet_Id] [int] IDENTITY(1,1) NOT NULL,
	[Movimiento_Id] [int] NOT NULL,
	[MovDet_Secuencia] [numeric](3, 0) NOT NULL,
	[OrdCor_Id] [int] NULL,
	[OrdCorPaq_Numero] [int] NULL,
	[MovDet_Color] [varchar](50) NOT NULL,
	[MovDet_Talla] [varchar](50) NOT NULL,
	[Combinacion_Id] [int] NOT NULL,
	[Talla_Id] [int] NOT NULL,
	[MovDet_Avance] [int] NULL,
 CONSTRAINT [PK_PR_MovimientoDetalle] PRIMARY KEY CLUSTERED 
(
	[MovDet_Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  ForeignKey [FK_PR_Movimiento_PR_OrdenProduccion]    Script Date: 11/20/2011 23:04:24 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PR_Movimiento_PR_OrdenProduccion]') AND parent_object_id = OBJECT_ID(N'[dbo].[PR_Movimiento]'))
ALTER TABLE [dbo].[PR_Movimiento]  WITH CHECK ADD  CONSTRAINT [FK_PR_Movimiento_PR_OrdenProduccion] FOREIGN KEY([OrdPro_Id])
REFERENCES [dbo].[PR_OrdenProduccion] ([OrdPro_Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PR_Movimiento_PR_OrdenProduccion]') AND parent_object_id = OBJECT_ID(N'[dbo].[PR_Movimiento]'))
ALTER TABLE [dbo].[PR_Movimiento] CHECK CONSTRAINT [FK_PR_Movimiento_PR_OrdenProduccion]
GO
/****** Object:  ForeignKey [FK_PR_MovimientoDetalle_PR_Movimiento]    Script Date: 11/20/2011 23:04:25 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PR_MovimientoDetalle_PR_Movimiento]') AND parent_object_id = OBJECT_ID(N'[dbo].[PR_MovimientoDetalle]'))
ALTER TABLE [dbo].[PR_MovimientoDetalle]  WITH CHECK ADD  CONSTRAINT [FK_PR_MovimientoDetalle_PR_Movimiento] FOREIGN KEY([Movimiento_Id])
REFERENCES [dbo].[PR_Movimiento] ([Movimiento_Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PR_MovimientoDetalle_PR_Movimiento]') AND parent_object_id = OBJECT_ID(N'[dbo].[PR_MovimientoDetalle]'))
ALTER TABLE [dbo].[PR_MovimientoDetalle] CHECK CONSTRAINT [FK_PR_MovimientoDetalle_PR_Movimiento]
GO
